<?php

/**
 * Company form.
 *
 * @package    BootcampApp
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class CompanyForm extends BaseCompanyForm {

    public function configure() {

        $this->configureWidgets();
        $this->configureFieldLabels();
    }

    /**
     * Sets label to display in form render
     */
    private function configureFieldLabels() {
        $this->getWidget('company_name')->setLabel('company name');
        $this->getWidget('founded_at')->setLabel('founded_at');
        $this->getWidget('tagline')->setLabel('tagline');
        $this->getWidget('website')->setLabel('website');
        $this->getWidget('employees')->setLabel('employees');
        $this->getWidget('about')->setLabel('');
        $this->getWidget('short_pitch')->setLabel('Short pitch');
        $this->getWidget('description')->setLabel('');
        $this->getWidget('markets')->setLabel('');
        $this->getWidget('customer')->setLabel('Current or potential customers');
        $this->getWidget('problems')->setLabel('Customer problem');
        $this->getWidget('solutions')->setLabel('Our solution to customer problem');
        $this->getWidget('landscapes')->setLabel('Competitive landscape');
        $this->getWidget('advantages')->setLabel('Competitive advantages and barriers to entry');
        $this->getWidget('partner_plan')->setLabel('');
        $this->getWidget('business_model')->setLabel('');
        $this->getWidget('strategy')->setLabel('');
        $this->getWidget('affiliate_plan')->setLabel('');
        $this->getWidget('additional_details')->setLabel('');
    }

    /**
     * Configure widgets
     */
    private function configureWidgets(){
        $this->setWidget('about', new sfWidgetFormTextareaReloaded(array('max_length' => $this->getValidator('about')->getOption('max_length'))));
        $this->setWidget('short_pitch', new sfWidgetFormTextareaReloaded(array('max_length' => $this->getValidator('short_pitch')->getOption('max_length'))));
        $this->setWidget('description', new sfWidgetFormTextareaReloaded(array('max_length' => $this->getValidator('description')->getOption('max_length'))));
        $this->setWidget('markets', new sfWidgetFormTextareaReloaded(array('max_length' => $this->getValidator('markets')->getOption('max_length'))));
        $this->setWidget('customer', new sfWidgetFormTextareaReloaded(array('max_length' => $this->getValidator('customer')->getOption('max_length'))));
        $this->setWidget('problems', new sfWidgetFormTextareaReloaded(array('max_length' => $this->getValidator('problems')->getOption('max_length'))));
        $this->setWidget('solutions', new sfWidgetFormTextareaReloaded(array('max_length' => $this->getValidator('solutions')->getOption('max_length'))));
        $this->setWidget('landscapes', new sfWidgetFormTextareaReloaded(array('max_length' => $this->getValidator('landscapes')->getOption('max_length'))));
        $this->setWidget('advantages', new sfWidgetFormTextareaReloaded(array('max_length' => $this->getValidator('advantages')->getOption('max_length'))));
        $this->setWidget('partner_plan', new sfWidgetFormTextareaReloaded(array('max_length' => $this->getValidator('partner_plan')->getOption('max_length'))));
        $this->setWidget('business_model', new sfWidgetFormTextareaReloaded(array('max_length' => $this->getValidator('business_model')->getOption('max_length'))));
        $this->setWidget('strategy', new sfWidgetFormTextareaReloaded(array('max_length' => $this->getValidator('strategy')->getOption('max_length'))));
        $this->setWidget('affiliate_plan', new sfWidgetFormTextareaReloaded(array('max_length' => $this->getValidator('affiliate_plan')->getOption('max_length'))));
        $this->setWidget('additional_details', new sfWidgetFormTextareaReloaded(array('max_length' => $this->getValidator('additional_details')->getOption('max_length'))));

        $years = range(date('Y'), date('Y') - 100);
        $this->getWidget('founded_at')->setOption('years', array_combine($years, $years));
    }

}
